def convert_to_material_mapping(file_path):
    """
    从 txt 文件中读取素材名称，并转换为 MATERIAL_MAPPING 格式
    :param file_path: txt 文件路径
    :return: 转换后的 MATERIAL_MAPPING 字典
    """
    material_mapping = {}
    text_index = 0  # 用于生成 text_track_{index}_0 的索引

    # 读取 txt 文件
    with open(file_path, 'r', encoding='utf-8') as file:
        material_names = file.read().splitlines()  # 按行读取并去除换行符

    # 转换逻辑
    for name in material_names:
        # if name.startswith("文本_"):  # 处理文本类型
        #     key = f"text_track_{text_index}_0"
        #     value = (name, 0)  # 默认不允许重复
        #     text_index += 1
        # else:  # 处理其他类型
        #     # 根据名称猜测文件类型
        #     if "录屏" in name or "替换素材" in name:
        #         file_type = ".mp4"
        #     elif "图片" in name:
        #         file_type = ".JPG"
        #     else:
        #         file_type = ".mp4"  # 默认类型
        key = name
        value = (name, 0)  # 默认不允许重复
        material_mapping[key] = value

    return material_mapping


# 示例 txt 文件路径
file_path = "../materials.txt"  # 替换为实际文件路径

# 转换为 MATERIAL_MAPPING
material_mapping = convert_to_material_mapping(file_path)

# 打印结果
print("MATERIAL_MAPPING = {")
for key, value in material_mapping.items():
    print(f'    "{key}": {value},')
print("}")


# if  __name__ == "__main__":
#     import pyJianYingDraft as draft
#
#     draft_folder = draft.Draft_folder("C:\\Users\\wangdoudou\\AppData\\Local\\JianyingPro\\User Data\\Projects\\com.lveditor.draft")
#     draft_folder.inspect_material("主题蹭款-模版")

    # 或者
    # script = draft_folder.load_template("草稿名称")
    # script.inspect_material()
